<?php
use yii\helpers\Html;
use backend\utils\XHtml;
use yii\helpers\Url;

/* @var $this yii\web\View */

$this->title = '自定义图片';
$this->params['breadcrumbs'][] = ['label' => '资源管理', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => '图片管理', 'url' => ['images-index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<?php $this->beginBlock('content-header'); ?>
<?= $this->title . ' ' . XHtml::create('上传', ['images-create']) ?>
<?php $this->endBlock(); ?>
    <div class="box box-primary">
        <div class="box-body clearfix">
            <?php foreach ((array)$files as $img) { ?>
                <div class="picture-box">
                    <img class="img" src="<?= Yii::getAlias('@frontendUrl') ?>/images/<?= $img['filename'] ?>">
                    <div class="del" data-path="<?= $img['path'] ?>"><i class="fa fa-close text-danger"></i></div>
                    <div class="name" title="<?= $img['filename'] ?>"><?= $img['filename'] ?></div>
                </div>
            <?php } ?>
        </div>
    </div>
<?php $this->beginBlock('js'); ?>
    <script>
        $(".del").click(function () {
            if (confirm('您确定要删除该图片吗？')) {
                var that = $(this);
                var path = that.attr("data-path");
                $.post("<?=Url::to(['images-system-delete'])?>", {path: path}, function (result) {
                    if (result == 1) {
                        that.parent().remove();
                    }
                });
            }
        });
    </script>
<?php $this->endBlock(); ?>